package com.pedro.streamer.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.pedro.streamer.R;


public class ALiveChoosePicAdapter extends RecyclerView.Adapter<ALiveChoosePicAdapter.TopTabViewHolder> {


    private static final String TAG = "com.bmit.engineermode";

    private Context mContext;

    private OnTextClickListener clickListener;

    @Override
    public TopTabViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.choose_pic_layout, parent, false);
        mContext = parent.getContext();

        return new TopTabViewHolder(view);
    }

    static class TopTabViewHolder extends RecyclerView.ViewHolder {


        ImageView imageView;
        TextView textView;

        public TopTabViewHolder(View view) {
            //父类构造函数
            super(view);
            imageView = view.findViewById(R.id.image_view);
            textView = view.findViewById(R.id.text);


        }

    }

    @Override
    public void onBindViewHolder(@NonNull TopTabViewHolder holder, int position) {

        if (position == 0) {
            holder.textView.setVisibility(View.VISIBLE);
        } else {
            holder.textView.setVisibility(View.GONE);
        }


        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (clickListener != null) {
                    clickListener.onTextClick(position);
                }

            }
        });


    }


    public void setClickListener(OnTextClickListener clickListener) {
        this.clickListener = clickListener;
    }



    @Override
    public int getItemCount() {

        return 10;
    }

    public interface OnTextClickListener {
        void onTextClick(int position);
    }
}

